<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>picture_my</title>
<link rel="stylesheet" type="text/css" href="/networkforum/css/base.css" />
<link rel="stylesheet" type="text/css" href="/networkforum/css/picture_my.css" />
<script type="text/javascript" src="/networkforum/js/picture_main.js"></script>
<!–[if lt IE9]> 
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]–>
<script type="text/javascript">
var myajax = null;
function passwordInput(dis){
	var password = document.getElementById("password1");
	password.style.display = dis;
	document.getElementById("password2").style.display = dis;
}
function checkName(obj){
	var value = obj.value;
	myajax = getByAjax();
	myajax.init(null,"get",true);
	myajax.get("/networkforum/picture/check_group.do?pgName="+encodeURIComponent(value),checkBack);
	myajax = null;	
}
function checkBack(data){
	//var d = eval("("+data+")");
	var d = toJson(data);
	var nameInfo = document.getElementById("nameInfo");
	nameInfo.innerHTML = d.value;
	if(d.value == "可以使用"){
		nameInfo.style.color = "green";
	}
	else{
		nameInfo.style.color = "red";
	}
}
function createPictureGroup(){
	var pgName = document.getElementById("pgName");
	var isPublic = document.getElementById("isPublic");
	var password1 = document.getElementById("pass1");

	var data = new Array();
	data.push({"name":"pgName","value":pgName.value});
	data.push({"name":"isPublic","value":isPublic.checked?"公开":"加密"});
	data.push({"name":"password","value":password1.value});
	//登录页面后通过myajax获取进一步的信息
	myajax = getByAjax();
	myajax.init(data,"get",true);
	myajax.get("/networkforum/picture/create_group.do",createBack);
	myajax = null;	
}
function createBack(d){
	groupHandle('none');
	var P = new PICTURE();
	//P.GistOne(eval("("+d+")"));
	var notice = document.getElementById("notice");
	if(notice){
		notice.parentElement.removeChild(notice);
	}
	P.GistOne(toJson(d));
	P = null;
}
window.onload = function(){
	//页面加载完成后通过myajax获取进一步的信息
	myajax = getByAjax();
	myajax.init(null,"get",true);
	myajax.get("/networkforum/picture/get_groups.do",function(d){
		//var data = eval("("+d+")"); 
		var data = toJson(d);
		//当该用户有相册时才展示相册信息
		if(data.length>0){
			var pgmain = document.getElementById("pgmain");
			var notice = document.getElementById("notice");
			pgmain.removeChild(notice);
			//相册列表展示
			var P = new PICTURE();
			P.GistAll(data);	
			P = null;
		}
		//如果相册超过可视区域，则为相册添加滚动效果
		if(data.length>4){
			//跑马灯效果设置
			scorl = SCROL();
			scorl.init(pgmain,2,30);
			scorl.scrol();
		}
		window.parent.iFrameHeight();
	});

	//默认加载全部图片，按照日期排序，先传的排在最后面
	var P = new PICTURE();
	myajax.get("/networkforum/picture/my_all_picture.do?index=0&size=20",function(d){
		//var data = eval("("+d+")"); 
		var data = toJson(d);
		P.MyPicture(data.mp);
		//systemStyle(data.ss,"相册");
		P = null;
	});
	
	myajax = null;

	//添加scroll事件
	var param = {
		url:"/networkforum/picture/my_all_picture.do",
		size:20,
		callBack:scrollBack,
		target:window.parent,
		containerId:"inner"
	}
	page.scrolls(param);
}
function scrollBack(data){
	//相片展示
	var P = new PICTURE();
	P.MyPicture(data);	
	window.parent.iFrameHeight();
	P = null;
}
function loadByCase(event){
	event = event||window.event;
	var target = event.target||event.srcElement;
	if(target.tagName.toLowerCase()!="li"){
		return;
	}
	var key = target.innerHTML;
	var option,asc;
	if(key=="默认"){
		option = "upload_time";
		asc = false;
	}
	else if(key=="最早"){
		option = "upload_time";
		asc = true;
	}
	else if(key=="最多评论"){
		option = "review_times";
		asc = false;
	}
	else if(key=="最少评论"){
		option = "review_times";
		asc = true;
	}
	else if(key=="访问最少"){
		option = "visit_times";
		asc = true;
	}
	else if(key=="访问最多"){
		option = "visit_times";
		asc = false;
	}
	var _url = page.scrolls.method._getUrl();
	page.scrolls.method.setUrl(_url,{option:option,asc:asc});
	page.scrolls.method.setIndex(1);
	
	var url = page.scrolls.method.getUrl();
	//
	var myajax = getByAjax();
	myajax.init(null,"get",true);
	myajax.get(url+"&index=0&size=20",function(d){
		//var data = eval("("+d+")"); 
		var P = new PICTURE();
		var data = toJson(d);
		P.clear();
		P.MyPicture(data);
		P = null;
	});
	myajax = null;
}
function visitPicture(event){
	event = event || window.event;
	var target = event.target;
	if(target.tagName != "IMG"||!target.publishTime){
		return false;
	}
	var url = page.scrolls.method.getUrl();
	var targetId = target.index;
	window.parent.window.location = "/networkforum/visit/visit_picture.do?targetId="+targetId+"&loadUrl="+url;
}
</script>
</head>
<body>
    <section class="inner" id="inner">
        <section class="innerNav">
            <section class="innernavheader">
                <a target="_self" href="picture_upload.html"><img class="upload cursor" src="/networkforum/images/uploadpicture.jpg" /></a>
                <h4 onclick="groupHandle('');">创建相册</h4>
            </section>
            <section class="pictureGist">
                <!-- <h2 class="shadow">相册列表</h2> -->
                <img onclick="scorllHandle(-180);" class="pleft" src="/networkforum/images/pleft1.jpg"/>
                <section id="pginner" class="pginner radiusTop radiusButtom">
                    <ul class="pgmain" id="pgmain">
						<label id="notice" style = "float:left;width:65%;height: 100%;display:block;font-size:24px;text-align: center;">暂无相册</label>
                    </ul>
                </section> 
                <img onclick="scorllHandle(180)" class="pright" src="/networkforum/images/pright1.jpg"/>                    
            </section>
        </section>
        <ul id="leftinner" class="left innermain" onclick="visitPicture(event);">
            <section id="pictureNav" class="pictureNav">
            	<img src="/networkforum/images/pictureNav.jpg" />
            	<span>热门标签</span>
            	<div class="clear"></div>
	        	<section id="choicePicture">
        	
    	    	</section>	
            	<ul class="pnInner" id="pnu" onclick="loadByCase(event)">
	            	<li>默认</li>
            		<li>最多评论</li>
            		<li>访问最多</li>
            		<li>最早</li>
            		<li>最少评论</li>
            		<li>访问最少</li>
            	</ul>
                <img class="navCorner" src="/networkforum/images/pictureNavBottom.jpg" />
            	
            </section>
        </ul>
        <ul id="middleinner" class="middle innermain" onclick="visitPicture(event);">
            
        </ul>
        <ul id="rightinner" class="right innermain" onclick="visitPicture(event);">
        
        </ul>
        <!--<section id="innerPicture" class = "innerPicture alpha" style = "display:none;" onmouseout = "alphaHandle(event)">
            <h4 id="publishTime">上传时间</h4>
            <h4 id="replyTime">评论次数</h4>
        </section>-->
    </section>
        <section id="addGroup" style="display:none;" class="addGroup alpha8 radiusTop">
        	<span class="groupClose" onclick="groupHandle('none');">关闭</span>
       		<section class="groupmain radiusTop radiusButtom">
            	<h2 class="groupTitle">创建相册</h2>
                <section class="groupInfo name">
	                <span>相册名称:</span><input id="pgName" onblur="checkName(this);" type="text" />
	                <label id="nameInfo" class="nameInfo">名称长度不得超过10个汉字</label>
                </section>
                <section class="groupInfo ispublic">
    	           	<span>公开:</span><input id="isPublic" type="radio" name="isPublic" onchange="passwordInput('none');"/>
	                <span>加密:</span><input type="radio" checked="checked" name="isPublic" onchange="passwordInput('');"/>
                </section>
                <section id="password1" class="groupInfo password">
	                <span>密码:</span><input id="pass1" type="password" />
                </section>
                <section id="password2" class="groupInfo password">
                    <span>重新输入:</span><input id="pass2" type="password" />
                </section>
                <section class="groupInfo submit">
	                <input id="submitInnler" onclick="createPictureGroup();" type="button" value="确定"/>
                </section>
            </section>
        </section>    
</body>

<script type="text/javascript" src="/networkforum/js/base.js"></script>
<script type="text/javascript" src="/networkforum/js/myajax.js"></script>
<script type="text/javascript" src="/networkforum/js/scrolls.js"></script>
</html>
